package vrp;

import com.google.appengine.api.datastore.Key;

import java.util.Date;
import java.util.ArrayList;
import java.util.LinkedList;
//import java.util.LinkedList;

import javax.jdo.annotations.Element;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Order;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable
public class Planning {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent
    private Date date;

    @Persistent
    private int algorithm; //0 for Savings Heuristics, 1 for GRASP Meta-heuristics

    @Persistent
    private int distanceType; //0 for Driving, 1 for Straight-line

    @Persistent
    private double totalDistance;

    @Persistent
    private long totalTime;

    @Persistent
    //@Persistent(mappedBy = "planning")
    //@Element(dependent = "true")
    //@Order(extensions = @Extension(vendorName="datanucleus", key="list-ordering", value="deliveryDate asc"))
    private ArrayList<Route> routes;


    @Persistent
    private Date createdAt;

    public Planning(Date date, int algorithm, int distanceType, double totalDistance, long totalTime, ArrayList<Route> routes) {
        this.date = date;
        this.algorithm = algorithm;
        this.distanceType = distanceType;
        this.totalDistance = totalDistance;
        this.totalTime = totalTime;
        this.routes = routes;
    	this.createdAt = new Date();
    }

    public Key getKey() {
        return this.key;
    }

    public Date getDate() {
        return this.date;
    }

    public int getAlgorithm() {
        return this.algorithm;
    }

    public int getDistanceType() {
        return this.distanceType;
    }

    public double getTotalDistance() {
        return this.totalDistance;
    }

    public long getTotalTime() {
        return this.totalTime;
    }

    public ArrayList<Route> getRoutes() {
        return this.routes;
    }
    
    public Date getCreatedAt() {
        return this.createdAt;
    }
    
    public void setKey(Key someKey) {
    	this.key = someKey;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public void setAlgorithm(int algorithm) {
        this.algorithm= algorithm;
    }

    public void setDistanceType(int distanceType) {
        this.distanceType= distanceType;
    }

    public void setTotalDistance(double totalDistance) {
        this.totalDistance = totalDistance;
    }
    
    public void setTotalTime(long totalTime) {
        this.totalTime= totalTime;
    }    
    
    public void setRoutes(ArrayList<Route> routes) {
        this.routes= routes;
    }    

    public void setCreatedAt(Date createdAt) {
        this.createdAt= createdAt;
    }
}